package vip.george.bean.selector;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.annotation.MergedAnnotations;
import org.springframework.core.type.AnnotationMetadata;

public class MyImportSelector implements ImportSelector {


    /**
     * 有选择的注册bean
     * @param annotationMetadata 当前类被@Import引用 所在的配置类
     * @return 返回要注册的bean的类名，支持多个
     */
    @Override
    public String[] selectImports(AnnotationMetadata annotationMetadata) {
        MergedAnnotations annotations = annotationMetadata.getAnnotations();


        if (annotationMetadata.hasAnnotation("vip.george.bean.anno.MyAnno")) {
            return new String[]{"vip.george.bean.animal.Cat"};
        }
        return new String[0];
    }
}
